﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace QLTV.Forms.KhaiBao
{
    public partial class frmLichCongTacPopup : BaseForm
    {
        public frmLichCongTacPopup()
        {
            InitializeComponent();
        }

    
        public bool isNew { get; set; }
        public int _id { get; set; }

        private void frmLichCongTacPopup_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dsUsers.tblNhanSu' table. You can move, or remove it, as needed.
            this.tblNhanSuTableAdapter.Fill(this.dsUsers.tblNhanSu);
            if (isNew)
            {
                tblLichCongTacBindingSource.AddNew();
                startDateDateEdit.EditValue = DateTime.Now.Date;
                endDateDateEdit.EditValue = DateTime.Now.Date;
                người_lậpTextEdit.EditValue = Program.EmployeeName;
                người_lậpTextEdit.Properties.ReadOnly = true;
            }
            else
            {
                tblLichCongTacTableAdapter.FillBy(dsTongQuan.tblLichCongTac, _id);
            }
        }

        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

            tblLichCongTacBindingSource.EndEdit();
            tblLichCongTacTableAdapter.Update(dsTongQuan.tblLichCongTac);
            this.Close();
        }

        private void tên_Nhân_sựTextEdit_EditValueChanged(object sender, EventArgs e)
        {
            LookUpEdit lookup = sender as LookUpEdit;
            BindingManagerBase bm = BindingContext[lookup.Properties.DataSource];
            bm.Position = lookup.Properties.GetDataSourceRowIndex("iNhanSuID", lookup.EditValue);
        }
    }
}